#include<stdio.h>
#include<stdlib.h>
#include <unistd.h>
#define FIFO_FILE "MYFIFO"
int main(){
    FILE *fp;
    char buffer[ 1024];
    while(1)
    {
        if(( fp=fopen(FIFO_FILE,"w" ))==NULL){
            printf("open fifo failed.\n" );
            exit( 1);
        }
        printf("请输入: ");
        scanf("%s", buffer);
        printf("%s\n" ,buffer );
        if( fputs(buffer, fp)==EOF ){
            printf("fputs error!\n");
            exit(1);
        }
        if(fputs("", fp)==EOF){
            printf("write fifo error.\n");
            exit(1);
        }
        fclose(fp);
        usleep(100000);
    }
    return 0;
}